#include <cstdio>
#include <algorithm>
using namespace std;
int N, M, S, D;
const int MAXN = 501;
const int INF = 1000000000;
int G[MAXN][MAXN], cost[MAXN][MAXN];
int dis[MAXN], co[MAXN], pre[MAXN];
bool visit[MAXN] = {false};
void Dijkstra(int s)
{
    fill(dis, dis + MAXN, INF);
    dis[s] = 0;
    co[s] = 0;
    pre[s] = -1;
    int min, m;
    for (int i = 0; i < N; ++i)
    {
        min = INF;
        m = -1;
        for (int j = 0; j < N; ++j)
        {
            if (false == visit[j] && dis[j] < min)
            {
                min = dis[j];
                m = j;
            }
        }
        if (-1 == m)
            return;
        visit[m] = true;
        for (int j = 0; j < N; ++j)
        {
            if (false == visit[j] && G[m][j] != INF)
            {
                if (dis[m] + G[m][j] < dis[j])
                {
                    dis[j] = dis[m] + G[m][j];
                    pre[j] = m;
                    co[j] = co[m] + cost[m][j];
                }
                else if (dis[m] + G[m][j] == dis[j])
                {
                    if (co[m] + cost[m][j] < co[j])
                    {
                        pre[j] = m;
                        co[j] = co[m] + cost[m][j];
                    }
                }
            }
        }
    }
    return;
}
void print_path(int d)
{
    if (-1 == pre[d])
    {
        printf("%d ", d);
        return;
    }
    print_path(pre[d]);
    printf("%d ", d);
    return;
}
int main()
{
    fill(G[0], G[0] + MAXN * MAXN, INF);
    scanf("%d%d%d%d", &N, &M, &S, &D);
    for (int i = 0; i < M; ++i)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        scanf("%d%d", &G[u][v], &cost[u][v]);
        G[v][u] = G[u][v];
        cost[v][u] = cost[u][v];
    }
    Dijkstra(S);
    print_path(D);
    printf("%d %d\n", dis[D], co[D]);
}